package com.wanfajie.smsdistribute.db.bean.phone

import com.j256.ormlite.dao.ForeignCollection
import com.j256.ormlite.field.DatabaseField
import com.j256.ormlite.field.ForeignCollectionField
import com.j256.ormlite.table.DatabaseTable

@DatabaseTable(tableName = "sd_phone_group")
data class PhoneGroup(

        @DatabaseField(columnName = ID, generatedId = true)
        var id: Int? = null,

        @DatabaseField(columnName = GROUP_NAME_FIELD, unique = true)
        var groupName: String = ""
) {
    companion object {
        const val ID = "id"
        const val GROUP_NAME_FIELD = "name"
    }

    @ForeignCollectionField(eager = false, orderAscending = false, orderColumnName = PhoneNumber.ID)
    var phoneNumbers: ForeignCollection<PhoneNumber>? = null
}